﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MC_AI_002
{
    // static class that will store up start and stop times until the entries are printed, then it flushes the timer memory
    static class OperationTimer
    {
        static List<int> timeStart, timeEnd;

        static int starts = 0, ends = 0;

        static public void initialize()
        {
            timeStart = new List<int>();
            timeEnd = new List<int>();
        }
        static public void Start()
        {
            timeStart.Add(Environment.TickCount);
            starts++;
        }
        static public void End()
        {
            timeEnd.Add(Environment.TickCount);
            ends++;
        }

        // prints all start and corresponding end times, then resets all values
        static public void flush()
        {
            if (starts == ends)
            {// all starts have an end
                for (int i = 0; i < starts; i++)
                {
                    Console.WriteLine("i = {0}: dT = {1}",i, timeEnd.ElementAt(i) - timeStart.ElementAt(i));
                    if (i != 0 && i % 10 == 0)
                    {
                        Console.WriteLine("\tPress any key to continue list");
                        Console.ReadKey();
                        Console.Clear();
                    }
                }

            }

            starts = 0;
            ends = 0;
            timeStart.Clear();
            timeEnd.Clear();
        }

    }
}
